﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class comment : System.Web.UI.Page
{
    private DataTable srcGetcomm(string pagestart, string pagesize, string fid)
    {
        MysqlHelp bbsdata = new MysqlHelp();
        string conn = "select * from srccomment where srcid='" + fid + "'order by time DESC limit " + pagestart + "," + pagesize;
        DataTable recall = bbsdata.GetDatabysql(conn);
        return recall;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        UserPrivilege test = new UserPrivilege();
        test.SetUserSession("wangyong", "1");
        Response.Write(test.GetSessionName());
       string ssrcid /*= Request["srcid"].ToString()*/;
       ssrcid = "1";
       DataTable src = srcGetcomm("0", "10", ssrcid);
       Response.Write(string.Format("共有{0}条评论",src.Rows.Count));
       int i;
        for(i=0;i<src.Rows.Count;i++)
        {
            Response.Write("<table>");
            Response.Write(string.Format("<tr><td width='50%'>{0}发表的评论</td>",src.Rows[i]["username"]));
               if (test.IsSrcCommmgrPrivilege()==true)
             {
                 Response.Write(string.Format("<td width='10%'><a href='newpost.aspx?act=commentdel&&id={0}'>删除</a></td></tr>", src.Rows[i]["id"]));
             }
            Response.Write("</tr>");
            Response.Write(string.Format("<tr><td>{0}</td></tr>",src.Rows[i]["content"]));
            Response.Write(string.Format("<tr><td>时间 {0}</td></tr>",src.Rows[i]["time"]));
            Response.Write("</br></table>");
        }
        Response.Write("<tabel>");
        Response.Write("<tr><td>发表评论</td></tr>");
        Response.Write("<form action='newpost.aspx?act=newcomment' method='post'>");
        Response.Write("<tr><td width='10%'>内容：</td><td width=50%><textarea type='text' name='commentcontent'></textarea></td></tr>");
        Response.Write(string.Format("<tr><input name='postsrcid' type='hidden' value='{0}'/></br>", ssrcid));
        Response.Write("<input type='submit' name='commsub' value='提交' />&nbsp&nbsp");
        Response.Write("<input type='reset' name='commsret' value='重置' /></tr>");
        Response.Write("</table>");
    }
}
